<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="list" lay-title="违约金管理">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card hxr-layui-card" id="userlistv">
					<div class="layui-form hxradmin-card-header">
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label" style="width: 140px;">违约金创建时间范围</label>
								<div class="layui-input-inline" style="width: 250px;">
									<input type="text" name="val2" id='date' class="layui-input" readonly>
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">状态</label>
								<div class="layui-input-inline">
									<div class="layui-unselect layui-form-select">
										<div class="layui-select-title"><input name="status" type="text" value="" readonly class="layui-input layui-unselect"><i
											 class="layui-edge"></i></div>
										<dl class="layui-anim layui-anim-upbit">
											<dd class="layui-select-tips layui-this">选择状态</dd>
											<dd data='1'>待支付</dd>
											<dd data='2'>已支付</dd>
											<dd data='3'>退款待审核</dd>
											<dd data='4'>已退款</dd>
										</dl>
									</div>
								</div>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="reload" id="drawingssearch">搜索</button>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="excel" id="pexcel">导出数据</button>
							</div>
						</div>
					</div>
					<div class="layui-card-body">
						<!-- <div>
							<button class="layui-btn layuiadmin-btn-list" data-type="set">提款设置</button>
						</div> -->
						<table class="layui-hide" id="list-table" lay-filter="list-table"></table>
					</div>
				</div>
				<script type="text/html" id="list-toolbar">
					 {{#  if(d.status === 3){ }}
					<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>同意</a>
					<!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>驳回</a> -->
					{{#  } else{ }}
					  暂无操作
					{{#  } }}
				</script>
				<script type="text/html" id="status">
				  {{#  if(d.status === 1){ }}
				    <span class="layui-badge">待支付</span>
				  {{#  } else if(d.status === 2) { }}
				     <span class="layui-badge layui-bg-green">已支付</span>
					{{#  } else if(d.status === 3) { }}
					  <span class="layui-badge">退款待审核</span>
					  {{#  } else if(d.status === 4) { }}
					    <span class="layui-badge layui-bg-cyan">已退款</span>
				  {{#  } }}
				</script>
			</div>
		</div>
	</div>
</div>
<script>
	var formurl='drawings/drawingsform',formarea=['500px', '630px'];
	//表格数据渲染
	
	layui.use(['table', 'form','laydate'], function() {
		var table = layui.table,
			form = layui.form,
			$ = layui.$,laydate=layui.laydate;
			//日期范围
			  laydate.render({
			    elem: '#date'
			    ,range: true
			  });
			layui.admin.initlist(table,'deposit/list',240,[
						[{
							field: 'deposit_id',
							title: 'ID',
							width: 60
						}, {
							field: 'order_sn',
							title: '订单流水号',
							width: 200
						}, {
							field: 'real_name',
							title: '会员姓名',
							minWidth: 100
						}, /* {
							field: 'device_name',
							title: '设备名称',
							minWidth: 100
						}, */ {
							field: 'deposit_amount',
							title: '金额(元)',
							width: 100
						}/* , {
							field: 'pay_type_name',
							title: '支付方式',
							width: 150
						} */, {
							field: 'status',
							title: '状态',
							width: 150,
							templet: '#status'
						},{
							field: 'pay_time',
							title: '支付时间',
							width: 200
						},{
							field: 'create_time',
							title: '创建时间',
							width: 200
						}, {
							title: '操作',
							toolbar: '#list-toolbar',
							width: 150,
							fixed:'right'
						}]
					])

		//监听表格操作事件
		table.on('tool(list-table)', function(obj) {
			var data = obj.data;
			//处理
			if (obj.event === 'del') {//驳回
				layer.confirm('确定驳回申请?', function(index) {
					layui.admin.delF(table,'withdraw/review',{agent_withdraw_id:data.agent_withdraw_id,status:2});
				});
			} else if (obj.event === 'edit') { //同意
				layer.confirm('确定同意退还违约金吗', function(index) {
					layui.admin.ajax('deposit/review', {
						deposit_id:data.deposit_id
					}).then(function(res){
						layui.table.reload('list-table');
					});
				});
			}
		});
		//操作dom
		$('.layui-btn.layuiadmin-btn-list').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
		//搜索
		$('#drawingssearch').on('click', function() {
			var obj=$(this).parents('.layui-form-item');
			var val2 = obj.find('input[name="val2"]').val();
			var val3 = obj.find('input[name="status"]').attr('data');
			layui.admin.reloads({
				datemin:val2.split(' ')[0],
				datemax:val2.split(' ')[2],
				status:val3
			})
		});
		//导出
		$('#pexcel').on('click', function() {
			var obj=$(this).parents('.layui-form-item');
			var val2 = obj.find('input[name="val2"]').val();
			var val3 = obj.find('input[name="status"]').attr('data');
			layui.admin.excel(table,'deposit/list',
					{
						datemin:val2.split(' ')[0],
						datemax:val2.split(' ')[2],
						status:val3
					},'');
		});
	});
</script>
